import React, { Component } from 'react';
import myContext from "../../../utils/myContext"

export default class SonA extends Component {

  render() {
    return (
      <>
        <div>SonA</div>
        <myContext.Consumer>
          {
            (val) => (
              <>
                <p>name:{val.name}</p>
                <p>age:{val.age}</p>
                <input type="button" value="修改年龄"
                  onClick={() => val.changeAge(2)} />
              </>
            )
          }
        </myContext.Consumer>

      </>
    )
  }
}
